package com.luoran.bartalks.utils;

import java.math.BigDecimal;

import com.luoran.bartalks.action.vo.PackingListMaterielOfExportVo;

/**
 * 箱单物料取列名
 * 
 * @author WMM 2018年10月22日上午10:25:21
 * @version 1.0
 */
public enum EnumPackingListMaterielColumnName {

	NAME(0, "物料名称"), CODE(1, "物料编码"), LENGTH(2, "长度(cm)"), WIDTH(3, "宽度(cm)"), HEIGHT(4, "高度(cm)"), VOLUME(5,
			"体积(cm³)"), EMPTYWEIGHT(6, "净重"), GROSSWEIGHT(7,
					"毛重"), VALUE(8, "价值(元)"), TAKEPHOTO(9, "是否强制拍照"), QRCODE(10, "二维码信息"), TYPECODE(11, "所属分类编码");

	private final Integer value;
	private final String name;

	EnumPackingListMaterielColumnName(Integer value, String name) {
		this.value = value;
		this.name = name;
	}

	public Integer getValue() {
		return this.value;
	}

	public String getName() {
		return this.name;
	}

	public static String getColumnName(Integer value) {
		String name = "";
		switch (value) {
		case 0:
			name = NAME.getName();
			break;
		case 1:
			name = CODE.getName();
			break;
		case 2:
			name = LENGTH.getName();
			break;
		case 3:
			name = WIDTH.getName();
			break;
		case 4:
			name = HEIGHT.getName();
			break;
		case 5:
			name = VOLUME.getName();
			break;
		case 6:
			name = EMPTYWEIGHT.getName();
			break;
		case 7:
			name = GROSSWEIGHT.getName();
			break;
		case 8:
			name = VALUE.getName();
			break;
		case 9:
			name = TAKEPHOTO.getName();
			break;
		case 10:
			name = QRCODE.getName();
			break;
		case 11:
			name = TYPECODE.getName();
			break;
		default:
			name = "未知";
			break;
		}
		return name;
	}

	public static String getMethod(Integer value, PackingListMaterielOfExportVo data) {
		String text = "";
		switch (value) {
		case 0:
			text = data.getName();
			break;
		case 1:
			text = data.getCode();
			break;
		case 2:
			text = data.getLength().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 3:
			text = data.getWidth().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 4:
			text = data.getHeight().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 5:
			text = data.getVolume().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 6:
			text = data.getEmptyWeight().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 7:
			text = data.getGrossWeight().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 8:
			text = data.getValue().setScale(6, BigDecimal.ROUND_HALF_UP).toPlainString();
			break;
		case 9:
			text = data.getTakePhoto() == 0 ? "是" : "否";
			break;
		case 10:
			text = data.getQrCode();
			break;
		case 11:
			text = data.getTypeCode();
			break;
		default:
			text = "";
			break;
		}
		if (text == null) {
			text = "";
		}
		return text;
	}

}
